package com.example.bsxk.web;

import com.example.bsxk.dto.BaseResponse;
import com.example.bsxk.dto.KZTeacherAllThesis;
import com.example.bsxk.dto.KZTheAllMessage;
import com.example.bsxk.service.KZTeacherChoiceStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
public class KZTeacherChoiceStudentController {

    @Autowired
    KZTeacherChoiceStudentService service;
    //返回某一年某个老师的所有信息 /teacher/{id}/theses?year=
    @GetMapping("/teacher/{id}/theses")
    public List<KZTeacherAllThesis> theAllMessage(@PathVariable("id") Long id, @RequestParam("year") Integer year){
        return service.selectAll(id,year);

    }
    //返回某一年所有课题信息
    @GetMapping("/theses/{year}")
    public KZTheAllMessage theAllMessageByYeay(@PathVariable("year") Integer year){
        KZTheAllMessage allMessage = new KZTheAllMessage();
        allMessage.setTheses(service.teacherAllByYear(year));
        return allMessage;
    }


    //老师选定学生
    @PostMapping("/theses/{tid}/student/{sid}")
    public BaseResponse TeacherChoiceStudent(@PathVariable("tid")Integer tid,@PathVariable("sid")Long sid){
        if (service.istrue(tid,sid)){
            return BaseResponse.success();
        }
        return BaseResponse.fail2001();
    }
}
